package com.net.wanjian.networkhospitalmanager.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.adapter.base.RecyclerBaseAdapter;
import com.net.wanjian.networkhospitalmanager.bean.dopsminicex.SearchEvaluationRecordByTeacher;
import com.net.wanjian.networkhospitalmanager.utils.URLDecoderUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Description:
 * Created by lidongcai on 2017/8/16.
 * Email:  lidongcaiocc@163.com
 */

public class RecordTableAdapter extends RecyclerBaseAdapter<SearchEvaluationRecordByTeacher.DataBean.EvaluationRecordListBean, RecordTableAdapter.ViewHolder> {

    public RecordTableAdapter(Context context) {
        super(context);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_record_table_dop_cex, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, SearchEvaluationRecordByTeacher.DataBean.EvaluationRecordListBean item, int position) {
        if (item.getEvaluationRecordType().equals("0")){
            holder.itemRecordTableNameTv.setText("DOPS记录表");
        }else {
            holder.itemRecordTableNameTv.setText("MINICEX记录表");
        }
        String recordTime = URLDecoderUtil.getDecoder(item.getEvaluationRecordTime());

        holder.itemRecordTableDateTv.setText(recordTime);
        holder.itemRecordTableStudentTv.setText(URLDecoderUtil.getDecoder(item.getStudentTrueName()));
        holder.itemRecordTableAddressTv.setText(URLDecoderUtil.getDecoder(item.getEvaluationRecordLocation()));
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_record_table_name_tv)
        TextView itemRecordTableNameTv;
        @BindView(R.id.item_record_table_date_tv)
        TextView itemRecordTableDateTv;
        @BindView(R.id.item_record_table_student_tv)
        TextView itemRecordTableStudentTv;
        @BindView(R.id.item_record_table_address_tv)
        TextView itemRecordTableAddressTv;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
